# 无序数组，任意相邻元素不等


def find_index(li):
    if not li or (len(li) == 0):
        return -1

    if (len(li) == 1) or (li[0] < li[1]):
        return 0
    if li[len(li) - 1] < li[len(li) - 2]:
        return len(li) - 1

    l = 0
    r = len(li) - 1
    length = len(li)
    res = -1
    while l <= r:
        mid = (l + r) // 2
        if (li[mid] < li[mid - 1]) and (li[mid] < li[mid + 1]):
            res = mid
            break
        else:
            if li[mid] > li[mid - 1]:
                r = mid - 1
            else:
                l = mid + 1
    return res


if __name__ == '__main__':
    li = [100, 90, 88, 4, 62, 29, 91, 50, 7, 6]
    print(find_index(li))
